//
//  WelcomeViewController.swift
//  sina_yl
//
//  Created by 袁量 on 2017/5/22.
//  Copyright © 2017年 袁量. All rights reserved.
//

import UIKit
import SDWebImage
class WelcomeViewController: UIViewController {

    @IBOutlet weak var iconView: UIImageView!
    @IBOutlet weak var bottom: NSLayoutConstraint!
    override func viewDidLoad() {
        super.viewDidLoad()
        setUpAnimation()
        setUpIcon() 
        // Do any additional setup after loading the view.
    }
}

// MARK: - 设置 UI
extension WelcomeViewController {
    func setUpAnimation() {
        bottom.constant = UIScreen.main.bounds.size.height - 200
        UIView.animate(withDuration: 1.5, delay: 0.0, usingSpringWithDamping: 0.65, initialSpringVelocity: 0.0, options: [], animations: {
            self.view.layoutIfNeeded()
        }) { (_) in
            UIApplication.shared.keyWindow?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()!
        }
    }
    func setUpIcon() {
        let profileURLStr = UserAccountViewModel.shareIntance.account?.avatar_large
        iconView.sd_setImage(with: URL(string: profileURLStr ?? ""), placeholderImage: UIImage(named: "avatar_default_big"))
        iconView.layer.cornerRadius = iconView.bounds.size.width / 2
        iconView.layer.masksToBounds = true
    }
}
